<!DOCTYPE html>
<html>

<head>
    {% include INC_PATH+"inc/script.html" %}
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-9 animated fadeInRight">
                <div class="mail-box-header">
                    <h2>
                        管理分类
                    </h2>
                </div>
                <div class="mail-box">
                    <div class="ibox-content">
                        <form id="categoryFrom" method="post" class="form-horizontal" action="/admin/category/dosth" enctype="multipart/form-data">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">标题</label>

                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="title" value="{{obj.title}}" />
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">选择</label>
                                <div class="col-sm-10">
                                    <select class="form-control m-b" name="pid">
                                        <option value="0">顶级分类</option>
                                        {% for cat in cat %}
                                            <option value="{{cat.id}}">{{cat.title}}</option>
                                            {% if(cat.child)%}
                                                {% for child in cat.child %}
                                                    <option value="{{child.id}}">&nbsp;&nbsp;{{child.title}}</option>
                                                {% endfor %}
                                            {% endif %}
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序号(越大越前)</label>

                                <div class="col-sm-10">
                                    <input type="number" min="1" class="form-control" name="ordernum" value="{{obj.ordernum}}" />
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">上传封面图</label>
                                <div class="col-sm-10">
                                    <input type="file" class="form-control" accept="image/*" name="imgFile" />
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否锁定</label>
                                <div class="col-sm-10">
                                    <div class="radio i-checks">
                                        <label>
                                            <input type="radio" value="1" {% if(obj.is_locked == 1)%}
                                            checked="true" {% endif %} name="is_locked" /> <i></i> 是
                                        </label>
                                        <label>
                                            <input type="radio" value="0" name="is_locked"  {% if(obj.is_locked == 0)%}
                                            checked="true" {% endif %} /> <i></i> 否
                                        </label>
                                    </div>
                                  
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="button" id="submit_btn">保存内容</button>
                                    <button class="btn btn-white" type="button" onclick="javascript:history.go(-1);">取消</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <!-- 全局js -->
    {% include INC_PATH+"inc/commonJs.html" %}
    <script>
       
        $('#submit_btn').click(function(){
            var id = $('input[name=id]').val();
            var title = $('input[name=title]').val();
            var pid = $('select[name=pid]').val();
            var ordernum = $('input[name=ordernum]').val();
            if(!title){
                toastr.error('请填写分类标题!!');
                $('input[name=title]').focus();
                return false;
            }

            $('#categoryFrom').submit();


           /* $.ajax({
                
                type: "post",
                url: "/admin/category/dosth",
                data: {
                    "id":id,
                    "title":title,
                    "pid":pid,
                    "ordernum": ordernum ? ordernum : 0,
                    "image":img
                },
                
                dataType: "json",
                success: function(data){
                        if(data.errno > 0){
                                toastr.error(data.errmsg);
                                return false;
                        }else{
                                toastr.success(data.errmsg);
                            
                        }
                }
            });*/
        })
	</script>
</body>

</html>